/**
 * 
 */
package com.cchr.acms.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cchr.acms.dao.CaseInfoDAO;
import com.cchr.acms.model.CaseInfo;
import com.cchr.acms.model.CaseInfoQueryEntity;
import com.cchr.acms.service.CaseInfoService;

/**
 * @author Zeng
 *
 */
@Service
public class CaseInfoServiceImpl implements CaseInfoService{
 
    @Autowired
    private CaseInfoDAO caseInfoDAO;
     
    public int insertCaseInfo(CaseInfo caseInfo) {
        int result = caseInfoDAO.insertCaseInfo(caseInfo);
        return result;
    }
    
    public int updateCaseInfo(CaseInfo caseInfo){
    	int result = caseInfoDAO.updateCaseInfo(caseInfo);
    	return result;
    }
    
    public CaseInfo getCaseInfoById(int id){
    	return caseInfoDAO.getCaseInfoById(id);
    }

	public List<CaseInfo> getAllCaseInfo() {
		return caseInfoDAO.getAllCaseInfo();
	}

	public List<CaseInfo> queryAbuseInfo(CaseInfoQueryEntity entity, int recordIndex, int pageNum) {
		Map paramMap=new HashMap();
		if(entity != null)
		{
			paramMap.put("patientName", entity.getPatientName());
			paramMap.put("doctorName", entity.getDoctorName());
			paramMap.put("facilityName", entity.getFacilityName());
			paramMap.put("drugName", entity.getDrugName());
			paramMap.put("abuseStart", entity.getAbuseStart());
			paramMap.put("abuseEnd", entity.getAbuseEnd());
			paramMap.put("abusedAge", entity.getAbusedAge());
			paramMap.put("abusedcity", entity.getAbusedcity());
			paramMap.put("abusedstate", entity.getAbusedstate());
			paramMap.put("abusedcountry", entity.getAbusedcountry());
			paramMap.put("drugType", entity.getDrugType());
			paramMap.put("abuseType", entity.getAbuseType());
			paramMap.put("doctorType", entity.getDoctorType());
			paramMap.put("facilityType", entity.getFacilityType());
			paramMap.put("facilityCity", entity.getFacilityCity());
			paramMap.put("facilityState", entity.getFacilityState());
			paramMap.put("facilityCountry", entity.getFacilityCountry());
			paramMap.put("hasAttoney", entity.getHasAttoney());
			paramMap.put("insuranceType", entity.getInsuranceType());
		}
		
		paramMap.put("recordIndex", recordIndex);
		paramMap.put("pageNum", pageNum);
		return caseInfoDAO.getPagedCaseInfo(paramMap);
	}

	public int queryTotal(CaseInfoQueryEntity entity) {
		Map paramMap=new HashMap();
		if(entity != null)
		{
			paramMap.put("patientName", entity.getPatientName());
			paramMap.put("doctorName", entity.getDoctorName());
			paramMap.put("facilityName", entity.getFacilityName());
			paramMap.put("DrugName", entity.getDrugName());
			paramMap.put("abuseStart", entity.getAbuseStart());
			paramMap.put("abuseEnd", entity.getAbuseEnd());
			paramMap.put("abusedAge", entity.getAbusedAge());
			paramMap.put("abusedcity", entity.getAbusedcity());
			paramMap.put("abusedstate", entity.getAbusedstate());
			paramMap.put("abusedcountry", entity.getAbusedcountry());
			paramMap.put("drugType", entity.getDrugType());
			paramMap.put("abuseType", entity.getAbuseType());
			paramMap.put("doctorType", entity.getDoctorType());
			paramMap.put("facilityType", entity.getFacilityType());
			paramMap.put("facilityCity", entity.getFacilityCity());
			paramMap.put("facilityState", entity.getFacilityState());
			paramMap.put("facilityCountry", entity.getFacilityCountry());
			paramMap.put("hasAttoney", entity.getHasAttoney());
			paramMap.put("insuranceType", entity.getInsuranceType());
		}
		
		return caseInfoDAO.queryTotal(paramMap);
	}
}
